/**
 * See: http://check.sourceforge.net/doc/check_html/check_3.html#SEC4
 */

#include <stdlib.h>
#include <check.h>

#include "checkConfigurationHandler.h"
#include "check_netops.h"
#include "checkFunctionTracing.h"
#include "checkIpcOps.h"
#include "checkRtOps.h"
#include "checkTimeOps.h"

int ExecuteDaTests(Suite *pSuite, char *szLogName) {
	int nNumberFailed = 0;

	SRunner *srSuite = srunner_create(pSuite);
	srunner_set_log(srSuite, szLogName);
	srunner_run_all(srSuite, CK_VERBOSE);
	nNumberFailed = srunner_ntests_failed(srSuite);
	srunner_free(srSuite);
    return(nNumberFailed);
}

int main(void) {
	int number_failed = 0;

	/* see: http://check.sourceforge.net/doc/check_html/check_4.html#SEC21 */
	/* srunner_set_xml(srCommon, "../test-reports/TEST-common.xml"); */

	number_failed += ExecuteDaTests(configuration_handler_suite(), "../test-reports/TEST-ConfigurationHandler.log");
	number_failed += ExecuteDaTests(netops_suite(), "../test-reports/TEST-NetOps.log");
	number_failed += ExecuteDaTests(FunctionTracing_suite(), "../test-reports/TEST-FunctionTracing.log");
	number_failed += ExecuteDaTests(IpcOps_suite(), "../test-reports/TEST-IpcOps.log");
	number_failed += ExecuteDaTests(RtOps_suite(), "../test-reports/TEST-RtOps.log");
	number_failed += ExecuteDaTests(TimeOps_suite(), "../test-reports/TEST-TimeOps.log");

	return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
